<?php
function __autoload($className)
{
	//Controllers
	if(strpos($className,'Controller') !== false)
	{
		$file = CONTROLLERS_DIR.$className.'.php';
	}
	//Models
	elseif(file_exists(MODELS_DIR.$className.'.php'))	
	{
		$file = MODELS_DIR.$className.'.php';
	}
	//Else
	elseif(file_exists(LIB.$className.'.php'))
	{
		$file = LIB.$className.'.php';
	}
	//Absent
	else
	{
		$file = NULL;
	}
	
	//Include class
	if($file)
	{
		include_once($file);
	}
	else
	{
		throw new Exception('Class \''.$className.'\' is absent on server.');
	}
}
	